<template>
    <div class="LW_workOnline_div">
        <div class="LW_workOnline_top" style="background: #059EDF 100%">
            <div class="LW_workOnline_top_ico_div" @click="$router.push('/lineWork')">
                <a-icon type="arrow-left" class="LW_workOnline_top_ico" theme="outlined" />
            </div>
            <div class="LW_workOnline_top_menu">进场料具确认</div>
        </div>
        <div class="LW_workOnline_content">
            <ul class="LW_workOnline_ul">
                <li class="LW_workOnline_li" v-for="item in planDetail">{{item}}</li>
            </ul>
            <a-row :span="24" class="LW_workOnline_row">
                <a-col class="LW_workOnline_col">
                    <a-button type="default" class="LW_workOnline_button"  @click="sendStep()">料具确认</a-button>
                </a-col>
            </a-row>
        </div>
    </div>
</template>
<style >

</style>
<script>
    import ACol from "ant-design-vue/es/grid/Col";
    import ARow from "ant-design-vue/es/grid/Row";
    export default {
        name: "LineWorkSureTool",
        components: {ARow, ACol},
        mounted(){
            this.getInfoById();
        },
        data() {
            return {
                myStep: '3',
                name:'确认料具进',
                planDetail:null,
                id:'',
            }
        },
        methods:{

            sendStep(){
                let that = this;
                let methodName = "开始";
                let note = '';
                let currStepInfo = {};
                that.id =that.$route.params.id?that.$route.params.id:JSON.parse(localStorage.getItem("currStepInfo")).id;//路由参数计划编号
                that.$api.step(that.id,that.name,methodName,note).then((resp)=>{
                    if(resp.status === 200){
                        //let otherFailSendInfo = failSendInfo.filter(item=>item.UserId!==UserId);//其余的失败信息集合*/
                        console.log("计划开始成功");
                        currStepInfo.step = that.myStep;
                        currStepInfo.id = that.id;
                        currStepInfo.name = that.name;
                        localStorage.setItem("currStepInfo",JSON.stringify(currStepInfo));
                        that.$router.push({name: 'lineWorkTakePhoto',params: {step: that.myStep,id:that.id,name:that.name}})
                    }
                }).catch((error)=>{
                    alert("计划开始失败");
                    console.log(error);
                })

            },
            getInfoById(){
                let that = this;
                that.id =that.$route.params.id;
                that.$api.getPlanById(that.id).then(function(resp){
                    //状态码200
                    if(resp.status === 200){
                        //let otherFailSendInfo = failSendInfo.filter(item=>item.UserId!==UserId);//其余的失败信息集合*/
                        that.planDetail= resp.data.result.planDetail.机具.split(",");//已完成


                    }
                }).catch(function(error){
                    //请求失败
                    console.log("init person failed:"+error);

                })
            },
        }
    }
</script>

